/*
 * @Author: wangzz wangzhuang@outlook.com
 * @Date: 2024-05-26 22:11:07
 * @LastEditors: wangzz wangzhuang@outlook.com
 * @LastEditTime: 2024-05-26 23:11:11
 * @FilePath: \screw-utils\lib\Calendar.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
// 月份列表
const monthList = [
	'1',
	'2',
	'3',
	'4',
	'5',
	'6',
	'7',
	'8',
	'9',
	'10',
	'11',
	'12'
]

// 年
const year = [
	2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022,
	2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030
]
// 月
const month = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
// 星期
const week = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']

/**
 * 获取当前时间（年，月，日）
 * @param {* 实例化时间 } date
 */
const getNewDate = (date) => {
	const year = date.getFullYear()
	const month = date.getMonth() + 1
	const day = date.getDate()
	return { year, month, day }
}

const getDate = (year, month, day) => {
	return new Date(year, month, day)
}

const englishMonth = (month) => {
	let engMonth
	monthList.map(() => {
		engMonth = monthList[month]
	})
	return engMonth
}

const formatDate = (date) => {
	date = Number(date)
	return date < 10 ? `0${date}` : date
}

/**
 * 获取大写星期
 * @param {* 时间对象 } date { year, month, day }
 */
const getUppercaseWeekDay = (date) => {
	const weekDayObj = {
		1: '一',
		2: '二',
		3: '三',
		4: '四',
		5: '五',
		6: '六',
		0: '日'
	}
	const weekDay = getDate(date.year, date.month - 1, date.day).getDay()
	return weekDayObj[weekDay]
}

 const Calendar = {
	year,
	month,
	week,
	getNewDate,
	getDate,
	englishMonth,
	formatDate,
	getUppercaseWeekDay
}

export default {
    year,
	month,
	week,
	getNewDate,
	getDate,
	englishMonth,
	formatDate,
	getUppercaseWeekDay
}